<? Phpr_View::beginBlock("head") ?>
	<script type="text/javascript" src="modules/backend/resources/javascript/unload_manager.js"></script>
	<script type="text/javascript" src="modules/cms/resources/javascript/edit.js"></script>
	<script type="text/javascript" src="modules/cms/resources/javascript/pages.js"></script>
	
	<script type="text/javascript">
		UnloadManager.unload_message = 'The page has been changed. Unsaved data will be lost.';
	</script>
<? Phpr_View::endBlock() ?>

<? Phpr_View::beginBlock("view") ?>
	<ul class="breadcrumbs">
		<li><a href="<?= url('/cms/pages') ?>">Pages</a></li>
		<li><?= $this->app_page_title ?></li>
	</ul>

	<? if (!isset($fatalError)): ?>
		<div id="page_info"><? $this->renderPartial('page_info') ?></div>
	<? endif ?>
	
	<? if (!isset($fatalError)): ?>
		<table class="layoutTable">
			<tr>
				<td>
					<?= Phpr_Form::openTag(array('id'=>'form_element')) ?>
						<? $this->formRender() ?>

						<?= backend_ajax_button('<u>S</u>ave', 'onSave', array(), "prepareFunction: function(){phprTriggerSave();}, extraFields: {redirect: 0}, loadIndicator: {show: false}, onBeforePost: LightLoadingIndicator.show('Saving...'), onSuccess: function(){UnloadManager.reset_changes()}, onComplete: LightLoadingIndicator.hide, update: 'multi', onAfterUpdate: setupInfoSize, onAfterError: setupInfoSize") ?>
						<?= backend_ajax_button('Save and Close', 'onSave', array(), "prepareFunction: function(){phprTriggerSave();}, onBeforeScriptEval: function(){UnloadManager.reset_changes()}") ?>
						<?= backend_button('Close', array('href'=>url('/cms/pages'), 'onclick'=>'UnloadManager.reset_changes()')) ?>

						<? if($form_model->title == Cms_Page::default_static_page_name): ?>
							<input type="hidden" id="new_page_flag" value="1">
						<? endif ?>

						<div class="clear"></div>
					</form>
				</td>
				<td class="rightFixedColumn secondary_tabs">
					<? $this->renderPartial('content_side_tabs') ?>
				</td>
			</tr>
		</table>
	<? else: ?>
		<?= flash() ?>
		<p><a href="<?= url('/cms/pages') ?>">Return to the page list</a></p>
	<? endif ?>
<? Phpr_View::endBlock() ?>